function onloadcontenedor() {
    movil_menu();
    cambiar_onclinck();
}

function cerrarsession() {
    window.location = "wl?xact=2";
}

function cambiar_onclinck() {
    var lis_link = document.getElementById("nav-global-menu").getElementsByTagName("A");
    for (var i = 0; i < lis_link.length; i++) {
        var link = lis_link[i];
        var level = link.getAttribute("level");
        var target = link.getAttribute("target");
        if (level != "" && target != "_blank") {
            var href = link.getAttribute("href");
            href = href.indexOf("../") == 0 ? href.substr(3, href.length) : href;
            link.onclick = clic;
            link.setAttribute("href", href);
        }
    }
}

var clic = function menuclic() {
    try {
        if (this.getAttribute("href").indexOf("?") != -1)
            document.getElementById('workflow').src = this.getAttribute("href") + "&cabecera=0&fe_solini=" + new Date().getTime();
        else
            document.getElementById('workflow').src = this.getAttribute("href");
        if (this.getAttribute("level") != "") {
            var activos = document.getElementById('ja-cssmenu').getElementsByClassName("active");
            while (activos.length != 0) {
                try {
                    activos[0].setAttribute("class", activos[0].className.replace("active", ""));
                } catch (e) {
                }
                break;
            }
            document.getElementById(this.getAttribute("level")).className = "menu-item1 active";
            try {
                document.getElementById("menu1").className = "menu-item0 first-item";
            } catch (e) {
                console.log(">[" + e + "]");
            }
        }
    } catch (e) {
        console.log("error:" + e);
    }
    return false;
}

function ocultar_cabecera() {
    document.getElementById("modo_print0").style.display = "none";
    document.getElementById("nav-global").style.display = "none";
    document.getElementById("contenedor").style.top = "12px";
    document.getElementById("contenedor").style.left = "0px";
    document.getElementById("contenedor").style.right = "0px";
    document.getElementById("mostrarcabecera").style.display = "block";
}

function mostrar_cabecera() {
    document.getElementById("modo_print0").style.display = "block";
    document.getElementById("nav-global").style.display = "block";
    document.getElementById("contenedor").style.top = "62px";
    document.getElementById("contenedor").style.left = "1%";
    document.getElementById("contenedor").style.right = "1%";
    document.getElementById("mostrarcabecera").style.display = "none";
}

function mostrar_title(iframe) {
    try {
        if (iframe.contentWindow.document.title.substring(0, 1) == "<")
            document.title = "${CFG.no_system}";
        else
            document.title = iframe.contentWindow.document.title;
    } catch (e) {
        document.title = "${CFG.no_system}";
    }
}

function show_user_option() {
    var ele = document.getElementById('yui_3_4_1_3_1379007579603_8');
    if (ele.className == "more") {
        ele.className = "more open";
    } else {
        ele.className = "more";
    }
}

function movil_menu() {
    document.getElementById("page").innerHTML = "<iframe  src='wfm/menu_movil2.jsp?a' style='width:100%;height:100%;border:1px solid #2B6484;min-height:509px;' />";
}

var menu = false;
function ver_menu() {
    if (!menu) {
        document.getElementById("nav-global-menu-movil2").style.left = "0px";
        menu = true;
        if (menu2) {
            ver_menu2()
        }
    } else {
        document.getElementById("nav-global-menu-movil2").style.left = "-350px";
        menu = false;
    }
}

var menu2 = false;
function ver_menu2() {
    if (!menu2) {
        document.getElementById("nav-global-menu-movil3").style.right = "0px";
        menu2 = true;
        if (menu) {
            ver_menu();
        }
    } else {
        document.getElementById("nav-global-menu-movil3").style.right = "-200px";
        menu2 = false;
    }
}

function gopro(uri) {
    document.getElementById("workflow").src = uri.replace("../", "") + (uri.indexOf("?") > -1 ? "&" : "?") + "cabecera=false";
    ver_menu();
}

function cambiar_password() {
    var tos = "${empty applicationScope.acceso.workflow.master_login_url ? '..' : 'http://'}${applicationScope.acceso.workflow.master_login_url }/wf?co_conten=499";
    document.getElementById("workflow").src = tos;
}

function go_menu() {
    var s = document.getElementById("menu_select").value;
    if (s == "1") {
        var tos = "${empty applicationScope.acceso.workflow.master_login_url ? '..' : 'http://'}${applicationScope.acceso.workflow.master_login_url }/wf?co_conten=499";
        window.location = tos;
    } else if (s == "2") {
        cerrarsession()
    } else {
        window.location = s;
    }
}
